|
|
|
|
|
|
|
Listing 12.4 TREEVIEW.ZIPWorking with the Load and Click Events |
|
|
|
|
|
|
|
|
Private Sub Form_Load()
'Put the tree view on top of the tab
tv1.ZOrder 0
'Call our procedure
DisplayLeague "American League"
End Sub
Private Sub tsMain_Click()
Dim nTemp As Integer
nTemp = tsMain.SelectedItem.Index
DisplayLeague tsMain.Tabs(nTemp).Caption
End Sub |
|
|
|
|
|
|
|
|
Now your sample program is done. Figure 12.15 shows how the program looks. |
|
|
|
|
|
|
|
|
Figure 12.15
The sample application displays a list
of baseball teams when a tab is clicked. |
|
|
|
|
|
|
|
|
The crux of the project is the DisplayLeague procedure. First, this procedure creates a node for the League divisions: |
|
|
|
|
|
|
|
|
Set tempNode = tv1.Nodes.Add("R", tvwChild, "E", "East Division") |
|
|
|
|
|
|
|
|
The constant tvwChild tells the application to make this new node a child of the node "R". |
|
|
|
|
|
|
|
|
Then, to each Division node, several team nodes are added: |
|
|
|
|
|
|
|
|
Set tempNode = tv1.Nodes.Add("E", tvwChild, "E" & nCounter, sTemp) |
|
|
|
|
|
|
|
|
Notice that the first argument in the Add method is now "E", which is the unique key of the node of the Eastern Division. The "E1" node (which displays Yankees) knows that it is a child of the Eastern Division because of this key. |
|
|
|
|
|